<%@page import="dal.project.ProjectUtil"%>
<%@page import="dal.project.Project"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
		<title>Project Information Details</title>
		
		<link rel="stylesheet" href="CssFiles/MyCssStyle.css">
		
		<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.js"></script>
		<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
		
		<script type="text/javascript">
			
			$(document).ready(function(){
				
					
					/* $("#formAddProject").submit(function(e){
						e.preventDefault();
					}); */
				
				
					$("#btnUpdate").click(function(e){
						var isOk=true;
						
						dataString=$("#formAddProject").serialize();
						
						var prjId=$("input#projectId").val();
						var prjDate=$("input#projectDate").val();
						var prjTitle=$("input#projectTitle").val();
						var prjOwner=$("input#projectOwner").val();
						var prjLocation=$("input#projectLocation").val();
						
						//alert(prjTitle+"  "+prjOwner+"  "+prjLocation );
						
						dataString="projectId="+prjId+"&projectDate="+prjDate+"&projectTitle="+prjTitle+"&projectOwner="+prjOwner+"&projectLocation="+prjLocation;
						
						$.ajax({
							type:"POST",
							url:"UpdateProject",
							data:dataString,
							dataType:"json",
							
							success:function(data,textStatus,jqXHR){
								
								if(data.success){
									$("#statusText").html("");
									$("#statusText").append(data.statusText);
									
									$("input:text#projectId").val("");
									$("input:text#projectTitle").val("");
									$("input:text#projectOwner").val("");
									$("input:text#projectLocation").val("");
								}else{
									$("#statusText").html("");
									$("#statusText").append(data.statusText);
									
								}
								
							},
							
							error:function(){
							
							}
						
						});
					
					});
			
				
				
			});
			
			
			
		</script>
		
	</head>
	<body>
		 <!-- action="AddProject" method="post" -->
	
		<%
			String id=request.getParameter("projId");
			Project project=(Project)new ProjectUtil().get(id); 
			
			if(project==null){
		%>
				<b><font style="color: red;">Record for this id is not available</font></b>
		<%	
			}else{
		%>
			
				<form  id="formAddProject" >
					<fieldset style="width: 75%;  "   >
						<legend><b>Project Details</b></legend>
						
						<table>
							<input type="hidden" name="projectId" id="projectId" value="<%=project.getProjectId() %> " />
							<input type="hidden" name="projectDate" id="projectDate" value="<%=project.getDate() %> " />
							<tr>
								<td><b>Project Title</b></td>
								<td><input type="text" id="projectTitle" name="projectTitle" value="<%=project.getTitle()%> "></input>	</td>
							</tr>
							<tr>
								<td><b>Project Owner</b></td>
								<td><input type="text" id="projectOwner" name="projectOwner" value="<%=project.getOwner() %>"></input></td>
							</tr>
							<tr>
								<td><b>Project Location</b></td>
								<td><input type="text" id="projectLocation" name="projectLocation" value="<%=project.getLocation() %>"></input></td>
							</tr>
							<tr>
								<td></td>
								<td>  
									<input type="button" name="btnUpdate" id="btnUpdate" value="Update"  />
								</td>
							</tr>
						</table>
						
					</fieldset>
					
					
				
				</form>
				<div id="statusText">
				
				</div>
		<%
			}
		 %>
	</body>
</html>